
//注册微应用的基础配置信息。当浏览器 url 发生变化时，会自动检查每一个微应用注册的 activeRule 规则，符合规则的应用将会被自动激活。

import { registerMicroApps, start, addGlobalUncaughtErrorHandler } from 'qiankun'
// 微应用的信息
import apps from './app'

registerMicroApps(
    apps,
    {
        beforeLoad: (app) => {
            console.log('before load', app.name)
        },
        beforeMount: (app) => {
            console.log('before mount ', app.name)
        },
        afterMount: (app) => {
            console.log('after mount ', app.name)

            sessionStorage.setItem('currentApp', app.name)
        },
        beforeUnmount : (app) => {
            console.log('before unmount ', app.name)
        },
        afterUnmount: (app) => {
            sessionStorage.setItem('currentApp', undefined)
            console.log('after unmount ', app.name)
        }
    },
)

// 添加全局的未捕获异常处理器
addGlobalUncaughtErrorHandler((event) => {
    console.log(event)
})

export default start
